<template>
  <div>
    <van-form
      @submit="onSubmit"
      class='form_box'
    >
      <van-field
        v-model="name"
        name="name"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="phone"
        name="phone"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名',pattern:/^\d{11}$/ }]"
      />
      <van-field
        v-model="password"
        name="password"
        type='password'
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <van-field
        v-model="passwordPay"
        name="passwordPay"
        type='password'
        label="支付密码"
        placeholder="支付密码"
        :rules="[{ required: true, message: '请填写用户名'}]"
      />
      <div style="margin: 16px;">
        <van-button
          round
          block
          type="info"
          native-type="submit"
        >
          提交
        </van-button>
      </div>
    </van-form>
  </div>
</template>
<script>
// @ is an alias to /src
import {reg} from '@/api/login'
export default {
  name: "XXX",
  data() {
    return {
      name:'',
      phone:'',
      password:'',
      passwordPay:''
    };
  },
  methods: {
    onSubmit(values){
      reg(values).then(data=>{
        // console.log(data)
        if(data.code == 0){
          this.$router.replace('/login')
        }
      })
    }
  },
};
</script>
<style lang="less">
</style>